package com.snail.readyvr.mvp.presenter;

import com.snail.readyvr.mvp.contract.LoginActivityContract;
import com.snail.readyvr.mvp.model.LoginParam;
import com.snail.readyvr.rest.GetSessionUtils;
import com.snail.readyvr.rest.LoginRestClient;
import com.snail.readyvr.rest.LoginUtils;
import com.snail.readyvr.rest.RestClient;

import javax.inject.Inject;


/**
 * Created by MRKING on 2016/10/10.
 */

public class LoginActivityPresenter implements LoginActivityContract.Presenter {

    private LoginActivityContract.View mView;
    private LoginRestClient mRestClient;
    private RestClient mClient;

    @Inject
    public LoginActivityPresenter(LoginRestClient restClient, LoginActivityContract.View view, RestClient client) {
        mRestClient = restClient;
        mView = view;
        mClient = client;
    }
/*
    @Override
    public void getToken() {
        //GetTokenParam getTokenParam = new GetTokenParam(AppUtils.getWIFIMac(MyApplication.getmContext()));
        mRestClient.getToken(AppUtils.getWIFIMac(MyApplication.getmContext())).map(new HttpResultFunc<GetTokenResponse>())
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(new Subscriber<GetTokenResponse>() {
                    @Override
                    public void onCompleted() {

                    }

                    @Override
                    public void onError(Throwable e) {
                        mView.getTokenFaile(e);
                        e.printStackTrace();
                    }

                    @Override
                    public void onNext(GetTokenResponse response) {
                        mView.getTokenSuceess(response);
                    }
                });
    }*/

    @Override
    public void login(int from, LoginParam param) {
        LoginUtils.getToken(mRestClient, from, param);
    }

    @Override
    public void getSessionId(int from) {
        GetSessionUtils.getSession(mClient,from);
    }

    @Override
    public void start() {

    }
}
